package com.doge.service.admin.stat;

import com.doge.bean.pojo.goods.Goods;
import com.doge.bean.pojo.order.Order;
import com.doge.bean.pojo.user.User;
import com.doge.bean.pojo.user.UserExample;
import com.doge.bean.vo.stat.*;
import com.doge.mapper.GoodsMapper;
import com.doge.mapper.OrderGoodsMapper;
import com.doge.mapper.OrderMapper;
import com.doge.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @program: project2-wechat-mall
 * @description: 统计实现的接口类
 * @author: zhu lei
 * @create: 2021-11-30 21:24
 **/
@Service
public class StatServiceImpl implements StatService {
    @Autowired
    UserMapper userMapper;

    @Autowired
    GoodsMapper goodsMapper;

    @Autowired
    OrderGoodsMapper orderGoodsMapper;

    @Override
    public StatUserVO statUser() {
        StatUserVO statUserVO = new StatUserVO();
//        long users = userMapper.selectUsersByUser(user);
//        String day = userMapper.selectDayByUser(user);
//        初始化columns
        ArrayList<String> columns = new ArrayList<>();
//          赋值columns
        columns.add("day");
        columns.add("users");

//        初始化rows
        List<UserRowsDTO> rows = userMapper.getUserStatListByUser();
//        对columns和rows赋值
        statUserVO.setColumns(columns);
        statUserVO.setRows(rows);

        return statUserVO;
    }

    @Override
    public StatOrderVO statOrder( ) {
        StatOrderVO statOrderVO = new StatOrderVO();

//        初始化columns，并分别赋值
        ArrayList<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("orders");
        columns.add("customers");
        columns.add("amount");
        columns.add("pcr");
        statOrderVO.setColumns(columns);
        List<OrderRowsDTO> rows = orderGoodsMapper.getOrderStat();
//      给rows赋值
        statOrderVO.setRows(rows);
        return statOrderVO;
    }

    @Override
    public StatGoodsVO statGoods( ) {
        StatGoodsVO statGoodsVO = new StatGoodsVO();
        ArrayList<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("orders");
        columns.add("products");
        columns.add("amount");
        statGoodsVO.setColumns(columns);
        List<GoodsRowsDTO> rows = goodsMapper.getGoodStat();
        statGoodsVO.setRows(rows);
        return statGoodsVO;
    }
}